home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / WindowMaker / WINGs / wtest.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-03-27  |  18.1 KB  |  751 lines

  1. /*
  2.  * WINGs test application
  3.  */
  4.  
  5. #include "WINGs.h"
  6.  
  7. #include <stdio.h>
  8.  
  9.  
  10.  
  11. /*
  12.  * You need to define this function to link any program to WINGs.
  13.  * This will be called when the application will be terminated because
  14.  * on a fatal error.
  15.  */
  16. void
  17. wAbort()
  18. {
  19.     exit(1);
  20. }
  21.  
  22.  
  23.  
  24.  
  25. Display *dpy;
  26.  
  27. int windowCount = 0;
  28.  
  29. void
  30. closeAction(WMWidget *self, void *data)
  31. {
  32.     WMDestroyWidget(self);
  33.     windowCount--;
  34.     if (windowCount < 1)
  35.     exit(0);
  36. }
  37.  
  38.  
  39. void
  40. testOpenFilePanel(WMScreen *scr)
  41. {
  42.     WMOpenPanel *panel;
  43.     
  44.     windowCount++;
  45.     
  46.     /* get the shared Open File panel */
  47.     panel = WMGetOpenPanel(scr);
  48.     
  49.     WMRunModalFilePanelForDirectory(panel, NULL, "/usr/local", NULL, NULL);
  50.     
  51.     /* free the panel to save some memory. Not needed otherwise. */
  52.     WMFreeFilePanel(WMGetOpenPanel(scr));
  53. }
  54.  
  55.  
  56. void
  57. testFontPanel(WMScreen *scr)
  58. {
  59.     WMFontPanel *panel;
  60.     
  61.     windowCount++;
  62.     
  63.     panel = WMGetFontPanel(scr);
  64.     
  65.     WMShowFontPanel(panel);
  66.     
  67. /*    WMFreeFontPanel(panel);*/
  68. }
  69.  
  70.  
  71.  
  72. void
  73. testList(WMScreen *scr)
  74. {
  75.     WMWindow *win;
  76.     WMList *list;
  77.     char text[100];
  78.     int i;
  79.  
  80.     windowCount++;
  81.  
  82.     win = WMCreateWindow(scr, "testList");
  83.     WMSetWindowTitle(win, "List");
  84.     WMSetWindowCloseAction(win, closeAction, NULL);
  85.  
  86.     list = WMCreateList(win);
  87.     for (i=0; i<50; i++) {
  88.     sprintf(text, "Item %i", i);
  89.     WMAddListItem(list, text);
  90.     }
  91.     WMRealizeWidget(win);
  92.     WMMapSubwidgets(win);
  93.     WMMapWidget(win);
  94.  
  95.     
  96. }
  97.  
  98.  
  99. void
  100. testGradientButtons(WMScreen *scr)
  101. {
  102.     WMWindow *win;
  103.     WMButton *btn;
  104.     WMPixmap *pix1, *pix2;
  105.     RImage *back;
  106.     RColor light, dark;
  107.     WMColor *color, *altColor;
  108.  
  109.     windowCount++;
  110.     
  111.     /* creates the top-level window */
  112.     win = WMCreateWindow(scr, "testGradientButtons");
  113.     WMSetWindowTitle(win, "Gradiented Button Demo");
  114.     WMResizeWidget(win, 300, 200);
  115.  
  116.     light.red = 0x90;
  117.     light.green = 0x85;
  118.     light.blue = 0x90;
  119.     dark.red = 0x35;
  120.     dark.green = 0x30;
  121.     dark.blue = 0x35;
  122.     
  123.     color = WMCreateRGBColor(scr, 0x5900, 0x5100, 0x5900, True);
  124.     WMSetWidgetBackgroundColor(win, color);
  125.     WMReleaseColor(color);
  126.     
  127.     back = RRenderGradient(60, 24, &dark, &light, RGRD_DIAGONAL);
  128.     RBevelImage(back, RBEV_RAISED2);
  129.     pix1 = WMCreatePixmapFromRImage(scr, back, 0);
  130.     RDestroyImage(back);
  131.  
  132.     back = RRenderGradient(60, 24, &dark, &light, RGRD_DIAGONAL);
  133.     RBevelImage(back, RBEV_SUNKEN);
  134.     pix2 = WMCreatePixmapFromRImage(scr, back, 0);
  135.     RDestroyImage(back);
  136.  
  137.     color = WMWhiteColor(scr);
  138.     altColor = WMCreateNamedColor(scr, "red", True);
  139.  
  140.     btn = WMCreateButton(win, WBTMomentaryChange);
  141.     WMResizeWidget(btn, 60, 24);
  142.     WMMoveWidget(btn, 20, 100);
  143.     WMSetButtonBordered(btn, False);
  144.     WMSetButtonImagePosition(btn, WIPOverlaps);
  145.     WMSetButtonImage(btn, pix1);
  146.     WMSetButtonAltImage(btn, pix2);
  147.     WMSetButtonText(btn, "Cool");
  148.     WMSetButtonTextColor(btn, color);
  149.     WMSetButtonAltTextColor(btn, altColor);
  150.  
  151.     WMSetBalloonTextForView("This is a cool button", WMWidgetView(btn));
  152.  
  153.     btn = WMCreateButton(win, WBTMomentaryChange);
  154.     WMResizeWidget(btn, 60, 24);
  155.     WMMoveWidget(btn, 90, 100);
  156.     WMSetButtonBordered(btn, False);
  157.     WMSetButtonImagePosition(btn, WIPOverlaps);
  158.     WMSetButtonImage(btn, pix1);
  159.     WMSetButtonAltImage(btn, pix2);
  160.     WMSetButtonText(btn, "Button");
  161.     WMSetButtonTextColor(btn, color);
  162.  
  163.     WMSetBalloonTextForView("Este Θ outro balπo.", WMWidgetView(btn));
  164.  
  165.     WMReleaseColor(color);
  166.     color = WMCreateNamedColor(scr, "orange", True);
  167.  
  168.     btn = WMCreateButton(win, WBTMomentaryChange);
  169.     WMResizeWidget(btn, 60, 24);
  170.     WMMoveWidget(btn, 160, 100);
  171.     WMSetButtonBordered(btn, False);
  172.     WMSetButtonImagePosition(btn, WIPOverlaps);
  173.     WMSetButtonImage(btn, pix1);
  174.     WMSetButtonAltImage(btn, pix2);
  175.     WMSetButtonText(btn, "Test");
  176.     WMSetButtonTextColor(btn, color);
  177.  
  178.     WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!",
  179.                 WMWidgetView(btn));
  180.  
  181.     WMReleaseColor(color);
  182.     WMReleaseColor(altColor);
  183.  
  184.     WMRealizeWidget(win);
  185.     WMMapSubwidgets(win);
  186.     WMMapWidget(win);
  187. }
  188.  
  189.  
  190. void
  191. testScrollView(WMScreen *scr)
  192. {
  193.     WMWindow *win;
  194.     WMScrollView *sview;
  195.     WMFrame *f;
  196.     WMLabel *l;
  197.     char buffer[128];
  198.     int i;
  199.  
  200.     windowCount++;
  201.     
  202.     /* creates the top-level window */
  203.     win = WMCreateWindow(scr, "testScroll");
  204.     WMSetWindowTitle(win, "Scrollable View");
  205.     
  206.     WMSetWindowCloseAction(win, closeAction, NULL);
  207.     
  208.     /* set the window size */
  209.     WMResizeWidget(win, 300, 300);
  210.     
  211.     /* creates a scrollable view inside the top-level window */
  212.     sview = WMCreateScrollView(win);
  213.     WMResizeWidget(sview, 200, 200);
  214.     WMMoveWidget(sview, 30, 30);
  215.     WMSetScrollViewRelief(sview, WRSunken);
  216.     WMSetScrollViewHasVerticalScroller(sview, True);
  217.     WMSetScrollViewHasHorizontalScroller(sview, True);
  218.  
  219.     /* create a frame with a bunch of labels */
  220.     f = WMCreateFrame(win);
  221.     WMResizeWidget(f, 400, 400);
  222.     WMSetFrameRelief(f, WRFlat);
  223.  
  224.     for (i=0; i<20; i++) {
  225.     l = WMCreateLabel(f);
  226.     WMResizeWidget(l, 50, 18);
  227.     WMMoveWidget(l, 10, 20*i);
  228.     sprintf(buffer, "Label %i", i);
  229.     WMSetLabelText(l, buffer);
  230.     WMSetLabelRelief(l, WRSimple);
  231.     }
  232.     WMMapSubwidgets(f);
  233.     WMMapWidget(f);
  234.     
  235.     WMSetScrollViewContentView(sview, WMWidgetView(f));
  236.     
  237.     /* make the windows of the widgets be actually created */
  238.     WMRealizeWidget(win);
  239.     
  240.     /* Map all child widgets of the top-level be mapped.
  241.      * You must call this for each container widget (like frames),
  242.      * even if they are childs of the top-level window.
  243.      */
  244.     WMMapSubwidgets(win);
  245.  
  246.     /* map the top-level window */
  247.     WMMapWidget(win);
  248. }
  249.  
  250.  
  251. void
  252. testColorWell(WMScreen *scr)
  253. {
  254.     WMWindow *win;
  255.     WMColorWell *well1, *well2;
  256.  
  257.     windowCount++;
  258.  
  259.     win = WMCreateWindow(scr, "testColor");
  260.     WMResizeWidget(win, 300, 300);
  261.  
  262.     WMSetWindowCloseAction(win, closeAction, NULL);
  263.  
  264.     well1 = WMCreateColorWell(win);
  265.     WMResizeWidget(well1, 60, 40);
  266.     WMMoveWidget(well1, 100, 100);
  267.     WMSetColorWellColor(well1, WMCreateRGBColor(scr, 0x8888, 0, 0x1111, True));
  268.     well2 = WMCreateColorWell(win);
  269.     WMResizeWidget(well2, 60, 40);
  270.     WMMoveWidget(well2, 200, 100);
  271.     WMSetColorWellColor(well2, WMCreateRGBColor(scr, 0, 0, 0x8888, True));
  272.     
  273.     WMRealizeWidget(win);
  274.     WMMapSubwidgets(win);
  275.     WMMapWidget(win);
  276. }
  277.  
  278. void
  279. sliderCallback(WMWidget *w, void *data)
  280. {
  281.     printf("SLIEDER == %i\n", WMGetSliderValue(w));
  282. }
  283.  
  284.  
  285. void
  286. testSlider(WMScreen *scr)
  287. {
  288.     WMWindow *win;
  289.     WMSlider *s;
  290.  
  291.     windowCount++;
  292.     
  293.     win = WMCreateWindow(scr, "testSlider");
  294.     WMResizeWidget(win, 300, 300);
  295.     WMSetWindowTitle(win, "Sliders");
  296.  
  297.     WMSetWindowCloseAction(win, closeAction, NULL);
  298.  
  299.     s = WMCreateSlider(win);
  300.     WMResizeWidget(s, 16, 100);
  301.     WMMoveWidget(s, 100, 100);
  302.     WMSetSliderKnobThickness(s, 8);
  303.     WMSetSliderContinuous(s, False);
  304.     WMSetSliderAction(s, sliderCallback, s);
  305.  
  306.     s = WMCreateSlider(win);
  307.     WMResizeWidget(s, 100, 16);
  308.     WMMoveWidget(s, 100, 10);
  309.     WMSetSliderKnobThickness(s, 8);
  310.  
  311.     WMRealizeWidget(win);
  312.     WMMapSubwidgets(win);
  313.     WMMapWidget(win);
  314. }
  315.  
  316.  
  317. void
  318. testTextField(WMScreen *scr)
  319. {
  320.     WMWindow *win;
  321.     WMTextField *field, *field2;
  322.  
  323.     windowCount++;
  324.     
  325.     win = WMCreateWindow(scr, "testText");
  326.     WMResizeWidget(win, 400, 300);
  327.  
  328.     WMSetWindowCloseAction(win, closeAction, NULL);    
  329.  
  330.     field = WMCreateTextField(win);
  331.     WMResizeWidget(field, 200, 20);
  332.     WMMoveWidget(field, 20, 20);
  333.  
  334.     field2 = WMCreateTextField(win);
  335.     WMResizeWidget(field2, 200, 20);
  336.     WMMoveWidget(field2, 20, 50);
  337.     WMSetTextFieldAlignment(field2, WARight);
  338.  
  339.     WMRealizeWidget(win);
  340.     WMMapSubwidgets(win);
  341.     WMMapWidget(win);
  342.     
  343. }
  344.  
  345.  
  346. void
  347. testProgressIndicator(WMScreen *scr)
  348. {
  349.     WMWindow *win;
  350.     WMProgressIndicator *pPtr;
  351.  
  352.     windowCount++;
  353.     
  354.     win = WMCreateWindow(scr, "testProgressIndicator");
  355.     WMResizeWidget(win, 292, 32);
  356.  
  357.     WMSetWindowCloseAction(win, closeAction, NULL);    
  358.  
  359.     pPtr = WMCreateProgressIndicator(win);
  360.     WMMoveWidget(pPtr, 8, 8);
  361.     WMSetProgressIndicatorValue(pPtr, 75);
  362.  
  363.     WMRealizeWidget(win);
  364.     WMMapSubwidgets(win);
  365.     WMMapWidget(win);
  366.     
  367. }
  368.  
  369.  
  370. void
  371. testPullDown(WMScreen *scr)
  372. {
  373.     WMWindow *win;
  374.     WMPopUpButton *pop, *pop2;
  375.  
  376.     windowCount++;
  377.     
  378.     win = WMCreateWindow(scr, "pullDown");
  379.     WMResizeWidget(win, 400, 300);
  380.  
  381.     WMSetWindowCloseAction(win, closeAction, NULL);    
  382.  
  383.     pop = WMCreatePopUpButton(win);
  384.     WMResizeWidget(pop, 100, 20);
  385.     WMMoveWidget(pop, 50, 60);
  386.     WMSetPopUpButtonPullsDown(pop, True);
  387.     WMSetPopUpButtonText(pop, "Commands");
  388.     WMAddPopUpButtonItem(pop, "Add");
  389.     WMAddPopUpButtonItem(pop, "Remove");
  390.     WMAddPopUpButtonItem(pop, "Check");
  391.     WMAddPopUpButtonItem(pop, "Eat");
  392.  
  393.     pop2 = WMCreatePopUpButton(win);
  394.     WMResizeWidget(pop2, 100, 20);
  395.     WMMoveWidget(pop2, 200, 60);
  396.     WMSetPopUpButtonText(pop2, "Select");
  397.     WMAddPopUpButtonItem(pop2, "Apples");
  398.     WMAddPopUpButtonItem(pop2, "Bananas");
  399.     WMAddPopUpButtonItem(pop2, "Strawberries");
  400.     WMAddPopUpButtonItem(pop2, "Blueberries");
  401.  
  402.     WMRealizeWidget(win);
  403.     WMMapSubwidgets(win);
  404.     WMMapWidget(win);
  405.     
  406. }
  407.  
  408.  
  409. void
  410. testTabView(WMScreen *scr)
  411. {
  412.     WMWindow *win;
  413.     WMTabView *tabv;
  414.     WMTabViewItem *tab;
  415.     WMFrame *frame;
  416.     WMLabel *label;
  417.  
  418.     windowCount++;
  419.     
  420.     win = WMCreateWindow(scr, "testTabs");
  421.     WMResizeWidget(win, 400, 300);
  422.  
  423.     WMSetWindowCloseAction(win, closeAction, NULL);    
  424.  
  425.     tabv = WMCreateTabView(win);
  426.     WMMoveWidget(tabv, 50, 50);
  427.     WMResizeWidget(tabv, 300, 200);
  428.  
  429.     frame = WMCreateFrame(win);
  430.     WMSetFrameRelief(frame, WRFlat);
  431.     label = WMCreateLabel(frame);
  432.     WMResizeWidget(label, 100, 100);
  433.     WMSetLabelText(label, "Label 1");
  434.     WMMapWidget(label);
  435.  
  436.  
  437.     tab = WMCreateTabViewItemWithIdentifier(0);
  438.     WMSetTabViewItemView(tab, WMWidgetView(frame));
  439.     WMAddItemInTabView(tabv, tab);
  440.     WMSetTabViewItemLabel(tab, "Instances");
  441.  
  442.     frame = WMCreateFrame(win);
  443.     WMSetFrameRelief(frame, WRFlat);
  444.     label = WMCreateLabel(frame);
  445.     WMResizeWidget(label, 40, 50);
  446.     WMSetLabelText(label, "Label 2");
  447.     WMMapWidget(label);
  448.  
  449.  
  450.     tab = WMCreateTabViewItemWithIdentifier(0);
  451.     WMSetTabViewItemView(tab, WMWidgetView(frame));
  452.     WMAddItemInTabView(tabv, tab);
  453.     WMSetTabViewItemLabel(tab, "Classes");
  454.  
  455.  
  456.     frame = WMCreateFrame(win);
  457.     WMSetFrameRelief(frame, WRFlat);
  458.     label = WMCreateLabel(frame);
  459.     WMResizeWidget(label, 100, 100);
  460.     WMMoveWidget(label, 60, 40);
  461.     WMSetLabelText(label, "Label 3");
  462.     WMMapWidget(label);
  463.  
  464.     tab = WMCreateTabViewItemWithIdentifier(0);
  465.     WMSetTabViewItemView(tab, WMWidgetView(frame));
  466.     WMAddItemInTabView(tabv, tab);
  467.     WMSetTabViewItemLabel(tab, "Something");
  468.  
  469.     
  470.     frame = WMCreateFrame(win);
  471.     WMSetFrameRelief(frame, WRFlat);
  472.     label = WMCreateLabel(frame);
  473.     WMResizeWidget(label, 100, 100);
  474.     WMMoveWidget(label, 160, 40);
  475.     WMSetLabelText(label, "Label 4");
  476.     WMMapWidget(label);
  477.  
  478.     tab = WMCreateTabViewItemWithIdentifier(0);
  479.     WMSetTabViewItemView(tab, WMWidgetView(frame));
  480.     WMAddItemInTabView(tabv, tab);
  481.     WMSetTabViewItemLabel(tab, "Bla!");
  482.  
  483.  
  484.  
  485.     frame = WMCreateFrame(win);
  486.     WMSetFrameRelief(frame, WRFlat);
  487.     label = WMCreateLabel(frame);
  488.     WMResizeWidget(label, 100, 100);
  489.     WMMoveWidget(label, 160, 40);
  490.     WMSetLabelText(label, "Label fjweqklrj qwl");
  491.     WMMapWidget(label);
  492.     tab = WMCreateTabViewItemWithIdentifier(0);
  493.     WMSetTabViewItemView(tab, WMWidgetView(frame));    
  494.     WMAddItemInTabView(tabv, tab);
  495.     WMSetTabViewItemLabel(tab, "Weee!");
  496.  
  497.     
  498.     WMRealizeWidget(win);
  499.     WMMapSubwidgets(win);
  500.     WMMapWidget(win);
  501. }
  502.  
  503.  
  504. void
  505. splitViewConstrainProc(WMSplitView *sPtr, int indView,
  506.                int *minSize, int *maxSize)
  507. {
  508.     switch (indView) {
  509.     case 0:
  510.         *minSize = 20;
  511.     break;
  512.     case 1:
  513.         *minSize = 40;
  514.         *maxSize = 80;
  515.     break;
  516.     case 2:
  517.         *maxSize = 60;
  518.     break;
  519.     default:
  520.         break;
  521.     }
  522. }
  523.  
  524.  
  525. static void 
  526. resizeSplitView(XEvent *event, void *data)
  527. {
  528.     WMSplitView *sPtr = (WMSplitView*)data;
  529.  
  530.     if (event->type == ConfigureNotify) {
  531.     int width = event->xconfigure.width - 10;
  532.         
  533.     if (width < WMGetSplitViewDividerThickness(sPtr))
  534.         width = WMGetSplitViewDividerThickness(sPtr);
  535.  
  536.     if (width != WMWidgetWidth(sPtr) ||
  537.             event->xconfigure.height != WMWidgetHeight(sPtr))
  538.         WMResizeWidget(sPtr, width, event->xconfigure.height - 55);
  539.     }
  540. }
  541.  
  542. void
  543. appendSubviewButtonAction(WMWidget *self, void *data)
  544. {
  545.     WMSplitView *sPtr = (WMSplitView*)data;
  546.     char buf[64];
  547.     WMLabel *label = WMCreateLabel(sPtr);
  548.     
  549.     sprintf(buf, "Subview %d", WMGetSplitViewSubviewsCount(sPtr) + 1);
  550.     WMSetLabelText(label, buf);
  551.     WMSetLabelRelief(label, WRSunken);
  552.     WMAddSplitViewSubview(sPtr, WMWidgetView(label));
  553.     WMRealizeWidget(label);
  554.     WMMapWidget(label);
  555. }
  556.  
  557. void
  558. removeSubviewButtonAction(WMWidget *self, void *data)
  559. {
  560.     WMSplitView *sPtr = (WMSplitView*)data;
  561.     int count = WMGetSplitViewSubviewsCount(sPtr);
  562.     
  563.     if (count > 2) {
  564.         WMView *view = WMGetSplitViewSubviewAt(sPtr, count-1);
  565.     WMDestroyWidget(WMWidgetOfView(view));
  566.         WMRemoveSplitViewSubviewAt(sPtr, count-1);
  567.     }
  568. }
  569.  
  570. void
  571. orientationButtonAction(WMWidget *self, void *data)
  572. {
  573.     WMSplitView *sPtr = (WMSplitView*)data;
  574.     WMSetSplitViewVertical(sPtr, !WMGetSplitViewVertical(sPtr));
  575. }
  576.  
  577. void
  578. adjustSubviewsButtonAction(WMWidget *self, void *data)
  579. {
  580.     WMAdjustSplitViewSubviews((WMSplitView*)data);
  581. }
  582.  
  583. void
  584. testSplitView(WMScreen *scr)
  585. {
  586.     WMWindow *win;
  587.     WMSplitView *splitv1, *splitv2;
  588.     WMFrame *frame;
  589.     WMLabel *label;
  590.     WMButton *button;
  591.  
  592.     windowCount++;
  593.     
  594.     win = WMCreateWindow(scr, "testTabs");
  595.     WMResizeWidget(win, 300, 400);
  596.     WMSetWindowCloseAction(win, closeAction, NULL);    
  597.  
  598.     frame = WMCreateFrame(win);
  599.     WMSetFrameRelief(frame, WRSunken);
  600.     WMMoveWidget(frame, 5, 5);
  601.     WMResizeWidget(frame, 290, 40);
  602.     
  603.     splitv1 = WMCreateSplitView(win);
  604.     WMMoveWidget(splitv1, 5, 50);
  605.     WMResizeWidget(splitv1, 290, 345);
  606.     WMSetSplitViewConstrainProc(splitv1, splitViewConstrainProc);
  607.     WMCreateEventHandler(WMWidgetView(win), StructureNotifyMask,
  608.                          resizeSplitView, splitv1);
  609.  
  610.     button = WMCreateCommandButton(frame);
  611.     WMSetButtonText(button, "+");
  612.     WMSetButtonAction(button, appendSubviewButtonAction, splitv1);
  613.     WMMoveWidget(button, 10, 8);
  614.     WMMapWidget(button);
  615.     
  616.     button = WMCreateCommandButton(frame);
  617.     WMSetButtonText(button, "-");
  618.     WMSetButtonAction(button, removeSubviewButtonAction, splitv1);
  619.     WMMoveWidget(button, 80, 8);
  620.     WMMapWidget(button);
  621.     
  622.     button = WMCreateCommandButton(frame);
  623.     WMSetButtonText(button, "=");
  624.     WMMoveWidget(button, 150, 8);
  625.     WMSetButtonAction(button, adjustSubviewsButtonAction, splitv1);
  626.     WMMapWidget(button);
  627.     
  628.     button = WMCreateCommandButton(frame);
  629.     WMSetButtonText(button, "#");
  630.     WMMoveWidget(button, 220, 8);
  631.     WMSetButtonAction(button, orientationButtonAction, splitv1);
  632.     WMMapWidget(button);
  633.     
  634.     label = WMCreateLabel(splitv1);
  635.     WMSetLabelText(label, "Subview 1");
  636.     WMSetLabelRelief(label, WRSunken);
  637.     WMMapWidget(label);
  638.     WMAddSplitViewSubview(splitv1, WMWidgetView(label));
  639.  
  640.     splitv2 = WMCreateSplitView(splitv1);
  641.     WMResizeWidget(splitv2, 150, 150);
  642.     WMSetSplitViewVertical(splitv2, True);
  643.  
  644.     label = WMCreateLabel(splitv2);
  645.     WMSetLabelText(label, "Subview 2.1");
  646.     WMSetLabelRelief(label, WRSunken);
  647.     WMMapWidget(label);
  648.     WMAddSplitViewSubview(splitv2, WMWidgetView(label));
  649.  
  650.     label = WMCreateLabel(splitv2);
  651.     WMSetLabelText(label, "Subview 2.2");
  652.     WMSetLabelRelief(label, WRSunken);
  653.     WMMapWidget(label);
  654.     WMAddSplitViewSubview(splitv2, WMWidgetView(label));
  655.  
  656.     label = WMCreateLabel(splitv2);
  657.     WMSetLabelText(label, "Subview 2.3");
  658.     WMSetLabelRelief(label, WRSunken);
  659.     WMMapWidget(label);
  660.     WMAddSplitViewSubview(splitv2, WMWidgetView(label));
  661.         
  662.     WMMapWidget(splitv2);
  663.     WMAddSplitViewSubview(splitv1, WMWidgetView(splitv2));
  664.  
  665.     WMRealizeWidget(win);
  666.     WMMapSubwidgets(win);
  667.     WMMapWidget(win);
  668. }
  669.  
  670. #include "WUtil.h"
  671.  
  672.  
  673.  
  674. int main(int argc, char **argv)
  675. {
  676.     WMScreen *scr;
  677.     WMPixmap *pixmap;
  678.     
  679.     
  680.     /* Initialize the application */
  681.     WMInitializeApplication("Test", &argc, argv);
  682.     
  683.     /*
  684.      * Open connection to the X display.
  685.      */
  686.     dpy = XOpenDisplay("");
  687.     
  688.     if (!dpy) {
  689.     puts("could not open display");
  690.     exit(1);
  691.     }
  692.     
  693.     /* This is used to disable buffering of X protocol requests. 
  694.      * Do NOT use it unless when debugging. It will cause a major 
  695.      * slowdown in your application
  696.      */
  697. #ifdef DEBUG
  698.     XSynchronize(dpy, True);
  699. #endif
  700.     /*
  701.      * Create screen descriptor.
  702.      */
  703.     scr = WMCreateScreen(dpy, DefaultScreen(dpy));
  704.  
  705.     /*
  706.      * Loads the logo of the application.
  707.      */
  708.     pixmap = WMCreatePixmapFromFile(scr, "logo.xpm");
  709.     
  710.     /*
  711.      * Makes the logo be used in standard dialog panels.
  712.      */
  713.     WMSetApplicationIconImage(scr, pixmap); WMReleasePixmap(pixmap);
  714.     
  715.     /*
  716.      * Do some test stuff.
  717.      * 
  718.      * Put the testSomething() function you want to test here.
  719.      */
  720.  
  721.  
  722.     testColorWell(scr);
  723. #if 0
  724.     testTabView(scr);
  725.  
  726.     testFontPanel(scr);
  727.  
  728.     testSplitView(scr);
  729.  
  730.     testGradientButtons(scr);
  731.     testProgressIndicator(scr);
  732.  
  733.     testTextField(scr);
  734.  
  735.     testOpenFilePanel(scr);
  736.     testList(scr);
  737.     testScrollView(scr);
  738.  
  739.  
  740.     testSlider(scr);
  741.     testPullDown(scr);
  742. #endif
  743.     /*
  744.      * The main event loop.
  745.      * 
  746.      */
  747.     WMScreenMainLoop(scr);
  748.  
  749.     return 0;
  750. }
  751.